/**
 * Created by Administrator on 2025/5/7.
 * */
#ifndef DATAREPOSITORY_ERA
#define DATAREPOSITORY_ERA

#include "TaskModule.h"
#include "../GlobalParameters.h"
#include <mutex>
#include <thread>
#include <string>
#include <zmq.hpp>
#include "../include/zy_net.h"

extern "C" BaseObject *createDataRepository();
extern "C" void destroyDataRepository(BaseObject *p);

class DataRepository : public TaskModule {
public:
DataRepository();

~DataRepository();

void onCompute(buffer_table_t *input, buffer_table_t *output) override;

private:
    std::string topicAddr = "tcp://192.168.1.115:6001";
    std::string topicName = "MainController";
    zmq::context_t ctx;
    zmq::socket_t sub;
    zmq::socket_t req_AICFARNet_socket;
    std::string req_AICFARNet_address = "tcp://192.168.1.115:6002";
    zmq::socket_t req_AIPCNet_socket;
    std::string req_AIPCNet_address = "tcp://192.168.1.115:6003";
    zmq::socket_t req_AIE2ENet_socket;
    std::string req_AIE2ENet_address = "tcp://192.168.1.115:6004";
    int prevStep;
    IcrDb icrDb;
    std::mutex mutex_;
    std::thread serverThread;
};

#endif //TASK2_ERA
